<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    //实现一个once函数，传入参数只执行一次

    function once(func) {
      var tag = true;

      return function () {
        if (tag == true) {
          func.apply(null, arguments);
          tag = false;
        }
        return undefined;
      };
    }
  </script>
</body>

</html>